package com.xc.service.impl;

import com.xc.dto.ResultDTO;
import com.xc.entity.CourseEntity;
import com.xc.entity.PermissionEntity;
import com.xc.mapper.CourseMapper;
import com.xc.mapper.PermissionMapper;
import com.xc.service.CourseService;
import com.xc.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CourseServiceImpl implements CourseService {
    @Autowired
    private CourseMapper courseMapper;


    @Override
    public ResultDTO add(CourseEntity courseEntity) {
        return ResultDTO.builder()
                .code(0)
                .count(courseMapper.add(courseEntity))
                .build();
    }

    @Override
    public ResultDTO update(CourseEntity courseEntity) {
        return ResultDTO.builder()
                .code(0)
                .count(courseMapper.update(courseEntity))
                .build();
    }

    @Override
    public ResultDTO delete(CourseEntity courseEntity) {
        return ResultDTO.builder()
                .code(0)
                .count(courseMapper.delete(courseEntity))
                .build();
    }

    @Override
    public ResultDTO updateEnable(CourseEntity courseEntity) {
        return ResultDTO.builder()
                .code(0)
                .count(courseMapper.updateEnable(courseEntity))
                .build();
    }

    @Override
    public ResultDTO findById(CourseEntity courseEntity) {
        return ResultDTO.builder()
                .code(0)
                .code(0)
                .data(courseMapper.findById(courseEntity))
                .build();
    }

    @Override
    public ResultDTO findAll(CourseEntity courseEntity) {

        return ResultDTO.builder()
                .code(0)
                .code(0)
                .count(courseMapper.count(courseEntity))
                .data(courseMapper.findAll(courseEntity))
                .build();
    }

    @Override
    public ResultDTO count(CourseEntity courseEntity) {
        return ResultDTO.builder()
                .code(0)
                .code(0)
                .count(courseMapper.count(courseEntity))
                .build();
    }

    @Override
    public ResultDTO findByName(CourseEntity courseEntity) {
        return null;
    }
}
